import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class MainClass extends JFrame {

	private JPanel contentPane;
	private JTextField textField_sex;
	private JTextField textField_height;
	private JTextField textField_weight;
	private JTextField textField;
	private JTextField textField_1;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MainClass frame = new MainClass();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public MainClass() {
		setTitle("\u4F53\u91CD\u6307\u6570\u8BA1\u7B97\u5668");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNewLabel_sex = new JLabel("\u6027\u522B\uFF08\u7537\u4E3A1\uFF0C\u5973\u4E3A2\uFF09");
		lblNewLabel_sex.setBounds(30, 35, 160, 18);
		contentPane.add(lblNewLabel_sex);
		
		JLabel lblNewLabel_height = new JLabel("\u8EAB\u9AD8\uFF08m\uFF09");
		lblNewLabel_height.setBounds(30, 90, 76, 18);
		contentPane.add(lblNewLabel_height);
		
		JLabel lblNewLabel_weight = new JLabel("\u4F53\u91CD\uFF08kg\uFF09");
		lblNewLabel_weight.setBounds(30, 145, 100, 18);
		contentPane.add(lblNewLabel_weight);
		
		textField_sex = new JTextField();
		textField_sex.setBounds(30, 60, 86, 24);
		contentPane.add(textField_sex);
		textField_sex.setColumns(10);
		
		textField_height = new JTextField();
		textField_height.setBounds(30, 115, 86, 24);
		contentPane.add(textField_height);
		textField_height.setColumns(10);
		
		textField_weight = new JTextField();
		textField_weight.setBounds(30, 170, 86, 24);
		contentPane.add(textField_weight);
		textField_weight.setColumns(10);
		
		JButton btnNewButton = new JButton("\u786E\u8BA4");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String a=textField_sex.getText();
				String b=textField_height.getText();
				String c=textField_weight.getText();
				double a1=Double.parseDouble(a);
				double b1=Double.parseDouble(b);
				double c1=Double.parseDouble(c);
				BMI s=new BMI(a1,b1,c1);
				double bm=s.bmicount();
				String d="您的体质指数为"+bm;
				textField.setText(d);
				if(bm<=18.4) {
					String e1="您的身材偏瘦，需要加强！";
					textField_1.setText(e1);
				}else if(bm<=23.9) {
					String e2="您的身材正常，注意保持！";
					textField_1.setText(e2);
				}else if(bm<=27.9) {
					String e3="您的身材过重，适当减重！";
					textField_1.setText(e3);
				}else {
					String e4="您的身材太重，注意身体！";
					textField_1.setText(e4);
				}
			}
		});
		btnNewButton.setBounds(240, 80, 113, 27);
		contentPane.add(btnNewButton);
		
		textField = new JTextField();
		textField.setBounds(203, 120, 150, 24);
		contentPane.add(textField);
		textField.setColumns(10);
		
		textField_1 = new JTextField();
		textField_1.setBounds(203, 160, 150, 24);
		contentPane.add(textField_1);
		textField_1.setColumns(10);
	}
}